<!DOCTYPE html>
<html xmlns:th="http://www.springframework.org/schema/jdbc">
<head>
    <meta charset="utf-8">
    <title>数据查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<style>
    .layui-form-pane .layui-form-label {
        width: auto !important;
    }
    .layui-table-cell{
        height:auto!important;
        white-space:normal;
    }

</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div class="layui-content">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline" id="DepartmentView"></div>
                        <script id="DepartmentTemplate" type="text/html">
                            <label class="layui-form-label" required>{{ d.label }}</label>
                            <div class="layui-input-inline" style="height: 38px;">
                                <select id="idcardNum" name="idcardNum" lay-search>
                                    <option value="">选择所属部门</option>
                                    {{# layui.each(d.list, function(index, item){ }}
                                    <option value="{{item.name}}">{{ item.name }}</option>
                                    {{# }); }}
                                </select>
                            </div>
                        </script>
                        <div class="layui-inline">
                            <label class="layui-form-label">用户姓名</label>
                            <div class="layui-input-inline" style="width: 90px">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">查询日期</label>
                            <div class="layui-input-inline">
                                <input type="text" name="stime" class="layui-input" id="stime" placeholder="yyyy-MM-dd HH:mm:ss">
                            </div>
                        </div>
                        <div class="layui-inline" style="margin-left: -30px">
                            <label class="layui-form-label">至</label>
                            <div class="layui-input-inline">
                                <input type="text" name="etime" class="layui-input" id="etime" placeholder="yyyy-MM-dd HH:mm:ss">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn-location"><i class="layui-icon"></i> 查询
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <fieldset class="table-search-fieldset">
            <legend>数据记录</legend>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </fieldset>

    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script th:inline="javascript">
    layui.use(['form', 'table', 'tree', 'util','laydate', 'layer', 'laytpl'], function () {
        let $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laytpl = layui.laytpl,
            laydate = layui.laydate,
            layer = layui.layer;

        function selectTemplate(data, name, label, templateId, viewId) {
            let list = {"name": name, "label": label,"list":data};
            let getTpl = document.getElementById('' + templateId + '').innerHTML;
            let view = document.getElementById('' + viewId + '');
            laytpl(getTpl).render(list, function (html) {
                view.innerHTML = html;
            });
            form.render('select');
        }

        $(document).ready(function () {
            let departments = [[${departments}]];
            selectTemplate(departments, "parent", "所属部门", "DepartmentTemplate", "DepartmentView");
        });

        table.render({
            elem: '#currentTableId',
            url: '/getVerifyPush',
            toolbar: '#toolbarDemo',
            width: 1250,
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            parseData:function(msg){
                console.log(msg);
                for (let i = 0; i < msg.data.length; i++) {
                    msg.data[i].verfyType=`${msg.data[i].verfyType}`.replace(0,"普通人员").replace(1,"白名单").replace(2,"黑名单");
                    msg.data[i].temperatureAlarm=`${msg.data[i].temperatureAlarm}`.replace(0,"正常").replace(1,"异常");
                }
                return msg;
            },
            cols: [
                [
                    {field: 'name', width: 100, title: '姓名'},
                    {field: 'createTime', width: 200, title: '测温时间', sort:true},
                    {field: 'deviceID', width: 200, title: '设备地址'},
                    {field: 'verfyType', width: 170, title: '人员角色'},
                    {field: 'temperature', width: 100, title: '温度'},
                    {field: 'temperatureAlarm', width: 100, title: '状态'},
                    {field: 'sanpPic', title: '照片', width: 200, sort: false,
                        templet: function (d) {
                            return '<div style="margin:  0 auto;text-align: center;">' +
                                '<img width="100px" height="120px" src=' + d.sanpPic + '></div>'
                        }
                    }
                ]
            ],
            limits: [10, 20, 25, 35, 50, 100],
            limit: 5,
            page: true
        });

        // 监听搜索操作:地点
        form.on('submit(data-search-btn-location)', function (data) {
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    idcardNum: data.field.idcardNum,
                    stime: data.field.stime,
                    etime: data.field.etime,
                    name: data.field.name
                }
            }, 'data');
            return false;
        });
        //日期时间选择器
        laydate.render({
            elem: '#stime'
            , type: 'datetime'
        });
        //日期时间选择器
        laydate.render({
            elem: '#etime'
            , type: 'datetime'
        });
    });
</script>
</body>
</html>